// --------------------------------------------------------------------------------------------------------------------
// <copyright file="IRoleEnvironment.cs" company="AzureContrib (Open source library http://azurecontrib.codeplex.com)">
//   Microsoft Public License (Ms-PL)
// </copyright>
// <summary>
//   Wrapper contract for Microsoft Windows Azure RoleEnvironment.
// </summary>
// --------------------------------------------------------------------------------------------------------------------

using System;
using System.Collections.Generic;

namespace AzureContrib.WindowsAzure.ServiceRuntime
{
	/// <summary>
	/// Wrapper contract for Microsoft Windows Azure RoleEnvironment.
	/// </summary>
	public interface IRoleEnvironment
	{
		/// <summary>
		/// Wrapper for Microsoft Windows Azure RoleEnvironment.Changing.
		/// </summary>
		event EventHandler<RoleEnvironmentChangingEventArgs> Changing;

		/// <summary>
		/// Wrapper for Microsoft Windows Azure RoleEnvironment.Changed.
		/// </summary>
		event EventHandler<RoleEnvironmentChangedEventArgs> Changed;

		/// <summary>
		/// Gets Microsoft Windows Azure RoleEnvironment.DeploymentId
		/// </summary>
		string DeploymentId { get; }

		/// <summary>
		/// Gets Microsoft Windows Azure RoleEnvironment.CurrentRoleInstance
		/// </summary>
		IRoleInstance CurrentRoleInstance { get; }

		/// <summary>
		/// Gets a value indicating whether Microsoft Windows Azure RoleEnvironment.IsAvailable.
		/// </summary>
		bool IsAvailable { get; }

		/// <summary>
		/// Gets the named <see cref="IRole"/>s running in the <see cref="IRoleEnvironment"/>.
		/// </summary>
		IDictionary<string, IRole> Roles { get; }

		/// <summary>
		/// Calls Microsoft Windows Azure RoleEnvironment.GetLocalResource
		/// </summary>
		/// <param name="localResourceName">
		/// The local Resource Name.
		/// </param>
		/// <returns>
		/// The get local resource.
		/// </returns>
		ILocalResource GetLocalResource(string localResourceName);

		/// <summary>
		/// Requests that the current role instance be stopped and restarted.
		/// </summary>
		void RequestRecycle();

		/// <summary>
		/// Microsoft Windows Azure RoleEnvironment.GetConfigurationSettingValue
		/// </summary>
		/// <param name="configurationSettingName">
		/// The configuration Setting Name.
		/// </param>
		/// <returns>
		/// The get configuration setting value.
		/// </returns>
		string GetConfigurationSettingValue(string configurationSettingName);

		/// <summary>
		/// Try Microsoft Windows Azure RoleEnvironment.GetConfigurationSettingValue
		/// </summary>
		/// <param name="configurationSettingName">
		/// The configuration Setting Name.
		/// </param>
		/// <param name="settingValue">
		/// The setting Value.
		/// </param>
		/// <returns>
		/// The try get configuration setting value.
		/// </returns>
		bool TryGetConfigurationSettingValue(string configurationSettingName, out string settingValue);
	}
}